<html>
<head>
    <title>HTML5 Exploding Camera Demo</title> 
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=yes">
</head>
 
<body>
    <div role="main">
 
        <video id="sourcevid" width="320" height="240" controls="controls" autoplay>No video</video>
         
 
        <input type="button" value="Start" onclick="start();" />
        <input type="button" value="Stop" onclick="stop();" />
    </div>
	
	<SCRIPT type="text/javascript">
						var video;
						 var onFailSoHard = function () {
								alert('erro');
							  };
						function start() {
							video = document.getElementById('sourcevid');
							navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
							 window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;    
							 alert(navigator.webkitGetUserMedia);
							 if (navigator.getUserMedia) {
								navigator.getUserMedia({video:true}, function(localmediastream) {
									video.src =	window.webkitURL.createObjectURL(localmediastream);
								  video.src = window.URL.createObjectURL(localmediastream);
								  video.controls = true;
									video.onloadedmetadata = function()  {
												  // Ready to go. Do some stuff.
												};
									 
								}, onFailSoHard);
								video.play();
							  } else if (navigator.webkitGetUserMedia) {
								navigator.webkitGetUserMedia({video: true}, function(localmediastream) {
								  video.src = window.URL.createObjectURL(localmediastream);
								  video.controls = true;
								}, onFailSoHard);
							  } else {
								onFailSoHard({target: video});
							  }
							 
						}						
						 
						function stop()
						{
						 video = document.getElementById('sourcevid');
						 video.src = "";
						}
  
	</script>
    
</body>
</html>
